﻿<%@ Page Title="Machine Details" Language="C#" MasterPageFile="~/MasterPage.master"
    AutoEventWireup="true" CodeFile="View_Machine.aspx.cs" Inherits="admin_View_Machine" %>

<asp:Content ID="Head" ContentPlaceHolderID="head" runat="Server">
    <link href="../styles/admin.css" rel="stylesheet" type="text/css" />
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
     <div id="top_menu">
        <div id="help_button">
            help
        </div>
    </div>
    <div id="page_title">
        ADMINISTRATION
    </div>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" runat="Server">
    <div id="left_content">
        <div class="menu">
            <ul>
                <li><a href="Home.aspx">Home</a></li>
                <li><a href="Mng_Client.aspx">Manage Clients</a></li>
                <li><a href="Mng_Site.aspx">Manage Sites</a></li>
                <li><a href="#" class="current">View Machine Details</a></li>
                <li><a href="Mng_Comp.aspx">Manage Components</a></li>
                <li><a href="Mng_Report.aspx">Manage Reports</a></li>
                <li><a href="Mng_WO.aspx">Manage Work Order</a></li>
                <li><a href="Mng_FaultsRecom.aspx">Manage Faults Recommendation</a></li>
            </ul>
        </div>
    </div>
    <!-- end of left content -->
    <div id="right_content">
        <div class="content_area">
            <h2>
                Machine Details
            </h2>
            <div class="form_box1">
                <asp:FormView ID="FormViewMachines" runat="server" DataKeyNames="machine_id" DataSourceID="MachinesObjectDataSource"
                    OnDataBound="FormViewMachines_DataBound">
                    <EditItemTemplate>
                        <table>
                            <tr>
                                <td class="label">
                                    Machine ID:
                                </td>
                                <td colspan="4">
                                    <asp:Label ID="machine_idLabel1" runat="server" Text='<%# Eval("machine_id") %>'
                                        CssClass="fields1" />
                                </td>
                            </tr>
                            <tr>
                                <td class="label">
                                    Machine Name:
                                </td>
                                <td colspan="4">
                                    <asp:TextBox ID="machineNameTextBox" runat="server" Text='<%# Bind("machineName") %>'
                                        CssClass="fields1" />
                                </td>
                            </tr>
                            <tr>
                                <td class="label">
                                    Site Name:
                                </td>
                                <td colspan="4">
                                    <asp:DropDownList ID="siteNameDropDownList" runat="server" DataSourceID="SitesObjectDataSource"
                                        DataTextField="siteName" DataValueField="site_id" SelectedValue='<%# Bind("site_id") %>'
                                        CssClass="dropDownList">
                                    </asp:DropDownList>
                                    <asp:ObjectDataSource ID="SitesObjectDataSource" runat="server" OldValuesParameterFormatString="original_{0}"
                                        SelectMethod="GetData" TypeName="DataAccess.i2iPortalTableAdapters.SitesTableAdapter">
                                    </asp:ObjectDataSource>
                                </td>
                            </tr>
                            <tr>
                                <td class="label">
                                    Status:
                                </td>
                                <td colspan="4">
                                    <asp:DropDownList ID="statusDropDownList" runat="server" SelectedValue='<%# Bind("status") %>'
                                        CssClass="dropDownList">
                                        <asp:ListItem Text="Activated" Value="Activated"></asp:ListItem>
                                        <asp:ListItem Text="Deactivated" Value="Deactivated"></asp:ListItem>
                                    </asp:DropDownList>
                                </td>
                            </tr>
                            <tr>
                                <td class="label">
                                    Photo:
                                </td>
                                <td colspan="3">
                                    <asp:FileUpload ID="photoFileUpload" runat="server" />
                                </td>
                                <td>
                                    <asp:Button ID="uploadButton" runat="server" Text="upload" OnClick="uploadButton_Click"
                                        CssClass="buttons" />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                </td>
                                <td colspan="3">
                                    <asp:Label ID="statusLabel" runat="server"></asp:Label>
                                    <asp:Label ID="photoLabel" runat="server" Text='<%# Bind("photo") %>' />
                                </td>
                                <td>
                                    <asp:Button ID="removeButton" runat="server" Text="remove" OnClick="removeButton_Click"
                                        Visible="False" CssClass="buttons" />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                </td>
                                <td colspan="3" align="center">
                                    <asp:Image ID="photoImage" runat="server" />
                                </td>
                                <td>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                </td>
                                <td colspan="2" class="Li_buttonC">
                                    <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"
                                        Text="Update" OnClick="UpdateButton_Click" />
                                </td>
                                <td colspan="2" class="Li_buttonC">
                                    <asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
                                        Text="Cancel" />
                                </td>
                            </tr>
                        </table>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <table>
                            <tr>
                                <td class="label">
                                    Machine ID:
                                </td>
                                <td>
                                    <asp:Label ID="machine_idLabel" runat="server" Text='<%# Eval("machine_id") %>' CssClass="fields" />
                                </td>
                            </tr>
                            <tr>
                                <td class="label">
                                    Machine Name:
                                </td>
                                <td>
                                    <asp:Label ID="machineNameLabel" runat="server" Text='<%# Bind("machineName") %>'
                                        CssClass="fields" />
                                </td>
                            </tr>
                            <tr>
                                <td class="label">
                                    Site ID:
                                </td>
                                <td>
                                    <asp:Label ID="site_idLabel" runat="server" Text='<%# Bind("site_id") %>' CssClass="fields" />
                                </td>
                            </tr>
                            <tr>
                                <td class="label">
                                    Status:
                                </td>
                                <td>
                                    <asp:Label ID="statusLabel" runat="server" Text='<%# Bind("status") %>' CssClass="fields" />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Photo:
                                </td>
                                <td>
                                    <asp:Button ID="removeButton" runat="server" Text="remove" OnClick="removeButton_Click"
                                        Visible="False" CssClass="buttons" />
                                </td>
                                <tr>
                                    <td>
                                    </td>
                                    <td align="center">
                                        <asp:Image ID="photoImage" runat="server" />
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                    </td>
                                    <td>
                                        <asp:Label ID="photoLabel" runat="server" Text='<%# Bind("photo") %>' CssClass="fields" />
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                    </td>
                                    <td class="Li_buttonC">
                                        <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit"
                                            Text="Edit" />
                                    </td>
                                </tr>
                        </table>
                    </ItemTemplate>
                </asp:FormView>
                <asp:ObjectDataSource ID="MachinesObjectDataSource" runat="server" OldValuesParameterFormatString="original_{0}"
                    SelectMethod="GetDataByMachineID" TypeName="DataAccess.i2iPortalTableAdapters.MachinesTableAdapter"
                    UpdateMethod="Update">
                    <UpdateParameters>
                        <asp:Parameter Name="site_id" Type="Int32" />
                        <asp:Parameter Name="machineName" Type="String" />
                        <asp:Parameter Name="status" Type="String" />
                        <asp:Parameter Name="photo" Type="String" />
                        <asp:Parameter Name="machineType_id" Type="Int32" />
                        <asp:Parameter Name="Original_machine_id" Type="Int32" />
                    </UpdateParameters>
                    <SelectParameters>
                        <asp:QueryStringParameter Name="machine_id" QueryStringField="machine_id" Type="Int32" />
                    </SelectParameters>
                </asp:ObjectDataSource>
            </div>
        </div>
        <div class="content_area2">
            <h2>
                Components on Machine
            </h2>
            <div class="form_box">
                <asp:GridView ID="GridViewComponents" runat="server" AllowSorting="True" AutoGenerateColumns="False"
                    DataKeyNames="component_id" DataSourceID="ComponentsObjectDataSource" OnSelectedIndexChanged="GridViewComponents_SelectedIndexChanged">
                    <Columns>
                        <asp:BoundField DataField="component_id" HeaderText="Component ID" InsertVisible="False"
                            ReadOnly="True" SortExpression="component_id">
                            <ItemStyle CssClass="column" />
                        </asp:BoundField>
                        <asp:BoundField DataField="componentName" HeaderText="Component Name" SortExpression="componentName">
                            <ItemStyle CssClass="column" />
                        </asp:BoundField>
                        <asp:CommandField SelectText="Details..." ShowSelectButton="True">
                            <ItemStyle CssClass="column" />
                        </asp:CommandField>
                    </Columns>
                </asp:GridView>
                <asp:ObjectDataSource ID="ComponentsObjectDataSource" runat="server" OldValuesParameterFormatString="original_{0}"
                    SelectMethod="GetDataByMachineID" TypeName="DataAccess.i2iPortalTableAdapters.ComponentsTableAdapter"
                    DeleteMethod="Delete">
                    <DeleteParameters>
                        <asp:Parameter Name="Original_component_id" Type="Int32" />
                    </DeleteParameters>
                    <SelectParameters>
                        <asp:QueryStringParameter Name="machine_id" QueryStringField="machine_id" Type="Int32" />
                    </SelectParameters>
                </asp:ObjectDataSource>
                <table>
                    <tr>
                        <td>
                            <asp:Button ID="CreateComponentButton" runat="server" Text="Add New Component" OnClick="CreateComponentButton_Click"
                                Width="200px" CssClass="buttons" />
                        </td>
                        <td>
                            <asp:Button ID="getDataSheet" runat="server" OnClick="getDataSheet_Click" Text="Get Data Sheet"
                                Width="200px" CssClass="buttons" />
                        </td>
                    </tr>
                </table>
            </div>
        </div>
        <div class="content_area2">
            <h2>
                Work Order
            </h2>
            <div class="form_box">
                <asp:GridView ID="GridViewWorkOrders" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                    DataKeyNames="workorder_id" DataSourceID="WorkOrdersObjectDataSource" OnSelectedIndexChanged="GridViewWorkOrders_SelectedIndexChanged"
                    OnRowDataBound="GridViewWorkOrders_RowDataBound" AllowSorting="True">
                    <Columns>
                        <asp:BoundField DataField="date_submitted" HeaderText="Date Submitted" SortExpression="date_submitted"
                            DataFormatString="{0:d}">
                            <ItemStyle CssClass="column" />
                        </asp:BoundField>
                        <asp:BoundField DataField="workorder_reference_no" HeaderText="WO Ref. No." SortExpression="workorder_reference_no">
                            <ItemStyle CssClass="column" />
                        </asp:BoundField>
                        <asp:BoundField DataField="action" HeaderText="Action Taken" SortExpression="action">
                            <ItemStyle CssClass="column" />
                        </asp:BoundField>
                        <asp:CommandField SelectText="Details..." ShowSelectButton="True">
                            <ItemStyle CssClass="column" />
                        </asp:CommandField>
                    </Columns>
                    <PagerStyle CssClass="pager" />
                    <EmptyDataTemplate>
                        There is no work order placed for this machine.
                    </EmptyDataTemplate>
                    <HeaderStyle CssClass="header" />
                </asp:GridView>
                <asp:ObjectDataSource ID="WorkOrdersObjectDataSource" runat="server" OldValuesParameterFormatString="original_{0}"
                    SelectMethod="GetDataByMachineID" TypeName="DataAccess.i2iPortalTableAdapters.WorkOrdersTableAdapter"
                    DeleteMethod="Delete">
                    <DeleteParameters>
                        <asp:Parameter Name="Original_workorder_id" Type="Int32" />
                    </DeleteParameters>
                    <SelectParameters>
                        <asp:QueryStringParameter Name="machine_id" QueryStringField="machine_id" Type="Int32" />
                    </SelectParameters>
                </asp:ObjectDataSource>
            </div>
        </div>
        <asp:LinkButton ID="BackButton" runat="server" PostBackUrl="Mng_Machine.aspx" CssClass="backbtn">Back</asp:LinkButton>
        <!-- end of right content -->
    </div>
</asp:Content>
